import { handleSearchLoading } from "@userList/search";
import { paymentMethodDict, partyStatusDict } from "../dict";
const searchLoading = ref(false);
const resetLoading = ref(false);
export const searchConfig = ({
  handleAction,
  refreshTable = (arg: any) => {},
  isPartyReview,
}: any) => {
  const comonSearchList = [
    {
      label: getProxyT("party16"),
      type: "input",
      model: "buss_id",
      allowClear: true,
      placeholder: getProxyT("party60"),
    },
    {
      label: getProxyT("party17"),
      type: "input",
      model: "party_name",
      allowClear: true,
      placeholder: getProxyT("party61"),
    },
    {
      label: getProxyT("party19"),
      type: "rangePicker",
      model: "party_start_end",
      placeholder: computed(() => [$t("base.startTime"), $t("base.endTime")]),
    },
    {
      label: getProxyT("party32"),
      type: "select",
      model: "payment_method",
      placeholder: getProxyT("party46"),
      searchClass: "search-item-width-150",
      allowClear: true,
      options: paymentMethodDict,
    },
    {
      label: getProxyT("party30"),
      type: "input",
      model: "initiator",
      allowClear: true,
      placeholder: getProxyT("party62"),
    },
    {
      label: getProxyT("party21"),
      type: "rangePicker",
      model: "operation_start_end",
      placeholder: computed(() => [$t("base.startTime"), $t("base.endTime")]),
    },
  ];
  const defineSearch = {
    okText: getProxyT("base.query"),
    cancelText: getProxyT("base.reset"),
    searchLoading,
    resetLoading,
    refreshTableData: async (searchParams: any, type: any) => {
      searchParams.status =
        searchParams.status === "" ? undefined : searchParams.status;
      handleSearchLoading(true, type, defineSearch);
      await refreshTable(searchParams);
      handleSearchLoading(false, type, defineSearch);
    },
    searchList: isPartyReview
      ? comonSearchList
      : comonSearchList.concat([
          {
            label: getProxyT("party33"),
            type: "select",
            model: "party_status",
            placeholder: getProxyT("party46"),
            searchClass: "search-item-width-150",
            allowClear: true,
            options: partyStatusDict,
          },
        ]),
  };
  return defineSearch;
};
